<template>
	<view class="container">
		<view class="bg-top" />

		<view class="card">
			<view class="answer">
				<view class="answer-info">
					<view class="info-status">
						<text>状态说明：</text>
						<view>
							<i class="status-part"></i>
							答对部分
						</view>
						<view>
							<i class="status-error"></i>
							错误或未填写
						</view>
					</view>
				</view>
				<view
					class="answer-section"
					v-for="(item, index) in questionList"
					:key="index"
				>
					<view class="title section-title">
						{{ renderNum(index) + item.questionTypeName }}
					</view>
					<view class="section-list">
						<view
							class="item"
							v-for="(v, i) in item.djExamPaperScores"
							:key="i"
						>
							<view
								:class="['item-box', renderStatus(v)]"
								@tap="viewDetail(index, i)"
							>
								{{ i + 1 }}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getErrorQuestion } from '@/net/lilunceyan.js'

let answerId
onLoad(params => {
	answerId = params.id
	getWrongList()
})

const renderNum = idx => {
	const questionNumArr = ['一', '二', '三', '四', '五', '六']
	return questionNumArr[idx] + '、'
}

const renderStatus = item => {
	if (item.customerAnswerScore === 0) return 'status-error'
	return item.customerAnswerScore === item.questionScore
		? 'status-success'
		: 'status-part'
}

const questionList = ref([])
const getWrongList = async () => {
	const { data } = await getErrorQuestion({ answerId })
	questionList.value = data.djExamPaperScoreVoList
}

const viewDetail = (typeIdx, quesIdx) => {
	uni.navigateTo({
		url: `./analysis?type=2&id=${answerId}&typeIdx=${typeIdx}&quesIdx=${quesIdx + 1}`
	})
}
</script>

<style lang="scss">
@import '/static/common.scss';

page {
	height: 100%;
}
.container {
	height: 100%;
	display: flex;
	flex-direction: column;
	padding: 20rpx;
	box-sizing: border-box;
}
.bg-top {
	width: 100%;
	height: 400rpx;
	position: fixed;
	top: 44px;
	left: 0;
	background-image: url('@/static/dangjian/wrong-bg.png');
}
.card {
	flex: 1;
	padding: 40rpx 20rpx;
	background-color: #fff;
	border-top-left-radius: 40rpx;
	border-top-right-radius: 40rpx;
	box-shadow: rgba(0, 0, 0, 0.08) 2px 2px 6px 0;
	position: relative;
	.title {
		font-size: 32rpx;
		font-weight: bold;
		color: #000;
	}
	.answer {
		padding: 0 20rpx;
		&-info {
			line-height: 1.5;
			.info-status {
				font-size: 24rpx;
				display: flex;
				align-items: center;
				color: #999;
				view {
					display: flex;
					align-items: center;
					& + view {
						margin-left: 24rpx;
					}
					i {
						width: 24rpx;
						height: 24rpx;
						margin-right: 8rpx;
						border-radius: 50%;
					}
				}
			}
		}
		&-section {
			.section-title {
				font-size: 30rpx;
				margin: 40rpx 0;
			}
			.section-list {
				display: flex;
				flex-wrap: wrap;
				.item {
					width: 20%;
					display: flex;
					justify-content: center;
					&:not(:nth-child(-n + 5)) {
						margin-top: 20rpx;
					}
					&-box {
						width: 84rpx;
						line-height: 84rpx;
						text-align: center;
						border-radius: 50%;
						// border: 1px solid #51bb88;
						// background-color: #e3f2ee;
					}
				}
			}
		}
	}
}
</style>
